package top.haichi.webpaper.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.haichi.webpaper.service.impl.FileServiceImpl;
import top.haichi.webpaper.utils.FileUtils;

@Configuration
public class StaticResourceConfig implements WebMvcConfigurer {

    @Value("${upload.directory}")
    private String uploadDirectory;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
                .addResourceHandler("/portraits/**")
                .addResourceLocations("file:" +uploadDirectory + "/files/portraits/");
        registry.addResourceHandler("/downloadpaper/**")
                .addResourceLocations("file:"+uploadDirectory+"/files/papers/");
    }
}
